/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package altaUsuario;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author usuario
 */
public class AltaUsuarioActionForm extends org.apache.struts.action.ActionForm {
    private String nombre;
    private String nif;

    public String getNif() {
        return nif;
    }

    public void setNif(String nif) {
        this.nif = nif;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (nombre == null || nombre.length() < 1) {
            errors.add("nombre", new ActionMessage("errors.required","Nombre"));
        }

        if (nif == null || nif.length() < 1) {
            errors.add("nif", new ActionMessage("errors.required","NIF"));
        }
        
        return errors;
    }
}
